/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "regiones")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Regiones.findAll", query = "SELECT r FROM Regiones r"),
    @NamedQuery(name = "Regiones.findByCUTRegion", query = "SELECT r FROM Regiones r WHERE r.cUTRegion = :cUTRegion"),
    @NamedQuery(name = "Regiones.findByRegion", query = "SELECT r FROM Regiones r WHERE r.region = :region"),
    @NamedQuery(name = "Regiones.findByCapitalRegional", query = "SELECT r FROM Regiones r WHERE r.capitalRegional = :capitalRegional")})
public class Regiones implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "CUT_Region")
    private Integer cUTRegion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 80)
    @Column(name = "Region")
    private String region;
    @Size(max = 45)
    @Column(name = "Capital_Regional")
    private String capitalRegional;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cUTRegion")
    private Collection<Provincias> provinciasCollection;

    public Regiones() {
    }

    public Regiones(Integer cUTRegion) {
        this.cUTRegion = cUTRegion;
    }

    public Regiones(Integer cUTRegion, String region) {
        this.cUTRegion = cUTRegion;
        this.region = region;
    }

    public Integer getCUTRegion() {
        return cUTRegion;
    }

    public void setCUTRegion(Integer cUTRegion) {
        this.cUTRegion = cUTRegion;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public String getCapitalRegional() {
        return capitalRegional;
    }

    public void setCapitalRegional(String capitalRegional) {
        this.capitalRegional = capitalRegional;
    }

    @XmlTransient
    public Collection<Provincias> getProvinciasCollection() {
        return provinciasCollection;
    }

    public void setProvinciasCollection(Collection<Provincias> provinciasCollection) {
        this.provinciasCollection = provinciasCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cUTRegion != null ? cUTRegion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Regiones)) {
            return false;
        }
        Regiones other = (Regiones) object;
        if ((this.cUTRegion == null && other.cUTRegion != null) || (this.cUTRegion != null && !this.cUTRegion.equals(other.cUTRegion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Regiones[ cUTRegion=" + cUTRegion + " ]";
    }
    
}
